<template>
  <div>
    <el-pagination
        v-if="list.length!==0"
        background
        small
        layout="prev, pager, next"
        :page-size="page.pageSize"
        @current-change="handlePage"
        :total="page.total">
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "Page",
  props: {
    methodName: '',
    page:{}
  },
  data() {
    return {
      list: []
    }
  },
  methods: {
    async init() {
      const promise = await this.$baseApi.callPostMethod(this.methodName, this.page);
      const data = promise.data
      if (data.code === 200) {
        this.list = data.data.records
        this.page.total = data.data.total
        this.$emit("getList",this.list)
      } else {
        this.$message.error(data.msg)
      }
    },
    handlePage(newNo) {
      this.page.pageNo = newNo
      this.init()
    },

  },
  mounted() {
    this.init()
  },
}
</script>

<style scoped>

</style>